<template>
    <view @tap="__e" class="order-item" :data-event-opts="[['tap', [['handleClick', ['$event']]]]]" hoverClass="none">
        <view class="order-item-header">
            <text class="time">{{ $root.f0 }}</text>
            <view :class="['status', order.union_status]">{{ '' + order.union_status_text + '' }}</view>
        </view>
        <view class="products">
            <sku-item @__l="__l" class="sku" :disableClick="true" :info="item" :vueId="'09f280fc-1-' + index" v-for="(item, index) in order.skus" :key="index"></sku-item>
        </view>
        <view @tap.stop.prevent="__e" class="total-price" :data-event-opts="[['tap', [['', ['$event']]]]]">
            <view class="remark">
                <text v-if="order.remark">{{ order.remark }}</text>
            </view>
            <view class="price-number">
                <view class="price-key">实付金额：</view>
                <view class="price">
                    <price-display @__l="__l" :disableClick="true" :info="order" prefix="pay_" vueId="09f280fc-2"></price-display>
                </view>
            </view>
        </view>
        <view class="close-time orange" v-if="closeTimeVisible">{{ '' + hours + ':' + minutes + ':' + seconds + ' 后关闭订单' }}</view>
        <view @tap.stop.prevent="__e" class="bottom-actions" :data-event-opts="[['tap', [['', ['$event']]]]]">
            <view @tap="__e" class="check-box" :data-event-opts="[['tap', [['handleCheck', ['$event']]]]]" v-if="isSelectMode">
                <image src="https://img121.7dun.com/20230207NewImg/hegui/xuan-on.png" style="width: 28rpx; height: 28rpx" v-if="isSelected"></image>
                <image src="https://img121.7dun.com/20230207NewImg/hegui/xuan.png" style="width: 28rpx; height: 28rpx" v-else></image>
            </view>
            <view style="flex-grow: 1"></view>
            <block v-if="order.union_status == 'pay_pending'">
                <button @tap="__e" class="bg-orange" :data-event-opts="[['tap', [['handleClick2', ['$event']]]]]" data-type="立即支付" hoverClass="hover">立即支付</button>
                <button @tap="__e" class="bg-cancel" :data-event-opts="[['tap', [['handleClick2', ['$event']]]]]" data-type="取消订单" hoverClass="hover">取消订单</button>
            </block>
            <block v-if="order.union_status == 'pending'">
                <button
                    @tap="__e"
                    class="bg-cancel"
                    :data-event-opts="[['tap', [['handleClick2', ['$event']]]]]"
                    data-type="核销码"
                    hoverClass="hover"
                    v-if="orderConfig.is_offline_use"
                >
                    核销码
                </button>
                <button
                    @tap="__e"
                    class="bg-orange"
                    :data-event-opts="[['tap', [['handleCoverChip', ['$event']]]]]"
                    data-type="兑换碎片"
                    hoverClass="hover"
                    v-if="order.is_chip_cover"
                >
                    兑换碎片
                </button>
                <button
                    @tap="__e"
                    class="bg-cancel"
                    :data-event-opts="[['tap', [['handleClick2', ['$event']]]]]"
                    data-type="返售"
                    hoverClass="hover"
                    v-if="!orderConfig.is_ban_return_sale"
                >
                    返售
                </button>
            </block>
            <block v-if="order.union_status == 'deliver_pending'">
                <button @tap="__e" class="bg-cancel" :data-event-opts="[['tap', [['handleClick2', ['$event']]]]]" data-type="取消订单" hoverClass="hover" v-if="order.is_closeable">
                    取消订单
                </button>
                <button class="bg-cancel" hoverClass="hover" openType="contact" v-if="isMiniappAndUseMiniappKf">联系客服</button>
                <button @tap="__e" class="bg-cancel" :data-event-opts="[['tap', [['openContact', ['$event']]]]]" hoverClass="hover" v-else>联系客服</button>
            </block>
            <button
                @tap="__e"
                class="bg-orange"
                :data-event-opts="[['tap', [['handleClick2', ['$event']]]]]"
                data-type="确认收货"
                hoverClass="hover"
                v-if="order.union_status == 'delivered'"
            >
                确认收货
            </button>
            <block v-if="order.union_status == 'comment_pending'"></block>
            <button
                @tap="__e"
                class="bg-cancel"
                :data-event-opts="[['tap', [['handleClick2', ['$event']]]]]"
                data-type="删除订单"
                hoverClass="hover"
                v-if="order.union_status == 'closed'"
            >
                删除订单
            </button>
            <block v-if="order.union_status == 'close_pending'">
                <button class="bg-cancel" hoverClass="hover" openType="contact" v-if="isMiniappAndUseMiniappKf">联系客服</button>
                <button @tap="__e" class="bg-cancel" :data-event-opts="[['tap', [['openContact', ['$event']]]]]" hoverClass="hover" v-else>联系客服</button>
            </block>
        </view>
    </view>
</template>

<script>
import skuItem from '@/components/SkuItem/SkuItem';
import priceDisplay from '@/components/PriceDisplay/PriceDisplay';
import tabBar from '@/components/TabBar/tabBar';
(global.webpackJsonp = global.webpackJsonp || []).push([
    ['pages/orderList/components/OrderItem'],
    {
        '0b5d': function (e, t, n) {
            'use strict';

            n.d(t, 'b', function () {
                return r;
            });
            n.d(t, 'c', function () {
                return o;
            });
            n.d(t, 'a', function () {
                return i;
            });
            var i = {
                SkuItem: function () {
                    return Promise.all([n.e('common/vendor'), n.e('components/SkuItem/SkuItem')]).then(n.bind(null, '3c3e'));
                },
                PriceDisplay: function () {
                    return n.e('components/PriceDisplay/PriceDisplay').then(n.bind(null, '6b05'));
                }
            };
            var r = function () {
                this.$createElement;
                var e = (this._self._c, this._f('dateformat')(this.order.created_at));
                this.setData(
                    Object.assign(
                        {},
                        {
                            $root: {
                                f0: e
                            }
                        }
                    )
                );
            };
            var o = [];
        },
        '892b': function (e, t, n) {},
        '97de': function (e, t, n) {
            'use strict';

            var i = n('892b');
            n.n(i).a;
        },
        af3b: function (e, t, n) {
            'use strict';

            n.r(t);
            var i = n('0b5d');
            var r = n('fa95');
            for (var o in r) {
                if (['default'].indexOf(o) < 0) {
                    (function (e) {
                        n.d(t, e, function () {
                            return r[e];
                        });
                    })(o);
                }
            }
            n('97de');
            var s = n('f0c5');
            var a = Object(s.a)(r.default, i.b, i.c, false, null, null, null, false, i.a, void 0);
            t.default = a.exports;
        },
        f6f4: function (e, t, n) {
            'use strict';

            (function (e) {
                var i = n('4ea4');
                Object.defineProperty(t, '__esModule', {
                    value: true
                });
                t.default = void 0;
                var r = i(n('8fc9'));
                var o = {
                    mixins: [i(n('452d')).default],
                    props: {
                        order: {
                            type: Object
                        },
                        isSelected: {
                            type: Boolean
                        },
                        isSelectMode: {
                            type: Boolean
                        }
                    },
                    data: function () {
                        return {
                            hours: '',
                            minutes: '',
                            seconds: '',
                            closeTimeVisible: false,
                            timer: null
                        };
                    },
                    computed: {
                        orderConfig: function () {
                            return this.$store.getters.setting.order;
                        }
                    },
                    filters: {
                        dateformat: function (e) {
                            return (0, r.default)(e, 'YYYY-MM-DD HH:mm:ss').format('YYYY-MM-DD HH:mm');
                        }
                    },
                    created: function () {
                        var that = this;
                        if ('pay_pending' === this.order.union_status && this.order.auto_closed_at) {
                            this.close_at = (0, r.default)(this.order.auto_closed_at);
                            if (this.close_at < (0, r.default)()) {
                                return;
                            }
                            this.closeTimeVisible = true;
                            this.setTime(this.close_at);
                            this.timer = setInterval(function () {
                                that.setTime(that.close_at);
                            }, 1000);
                        }
                    },
                    destroyed: function () {
                        clearInterval(this.timer);
                    },
                    methods: {
                        setTime: function (e) {
                            var t = (0, r.default)();
                            this.hours = this.fillNumber(e.diff(t, 'hours'));
                            this.minutes = this.fillNumber(e.diff(t, 'minutes') % 60);
                            this.seconds = this.fillNumber(e.diff(t, 'seconds') % 60);
                            if (e < t) {
                                clearInterval(this.timer);
                            }
                        },
                        fillNumber: function (e) {
                            return e < 10 ? '0' + e : e;
                        },
                        handleClick: function () {
                            if (this.isSelectMode) {
                                this.$emit('check');
                                return false;
                            }
                            e.navigateTo({
                                url: '/pages/orderDetail/index?uuid=' + this.order.uuid
                            });
                        },
                        handleClick2: function (e) {
                            this.$emit('action', {
                                order: this.order,
                                action: e.currentTarget.dataset.type
                            });
                        },
                        handleCheck: function () {
                            this.$emit('check');
                        },
                        handleCoverChip: function () {
                            e.navigateTo({
                                url: '/pages/coverChip/index?sku_id=' + this.order.skus[0].sku_id
                            });
                        }
                    }
                };
                t.default = o;
            }.call(this, n('543d').default));
        },
        fa95: function (e, t, n) {
            'use strict';

            n.r(t);
            var i = n('f6f4');
            var r = n.n(i);
            for (var o in i) {
                if (['default'].indexOf(o) < 0) {
                    (function (e) {
                        n.d(t, e, function () {
                            return i[e];
                        });
                    })(o);
                }
            }
            t.default = r.a;
        }
    }
]);
(global.webpackJsonp = global.webpackJsonp || []).push([
    'pages/orderList/components/OrderItem-create-component',
    {
        'pages/orderList/components/OrderItem-create-component': function (e, t, n) {
            n('543d').createComponent(n('af3b'));
        }
    },
    [['pages/orderList/components/OrderItem-create-component']]
]);
</script>
<style>
@import './OrderItem.css';
</style>
